package com.jy.wms.controller;

import com.github.pagehelper.Page;
import com.jy.wms.common.UUIDUtils;
import com.jy.wms.common.base.BaseController;
import com.jy.wms.common.base.JsonResult;
import com.jy.wms.common.base.ResultPage;
import com.jy.wms.pojo.WmsTurnoverRuleMiddle;
import com.jy.wms.service.WmsTurnoverRuleMiddleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @ClassName: WmsTurnoverRuleMiddleController
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @Author liyi
 * @Date Mon Sep 11 11:47:28 CST 2017
 */
@Controller
@RequestMapping("/wmsTurnoverRuleMiddle")
public class WmsTurnoverRuleMiddleController extends BaseController<WmsTurnoverRuleMiddleService,WmsTurnoverRuleMiddle> {

    @RequestMapping("/toWmsTurnoverRuleMiddle")
    public String toWmsTurnoverRuleMiddle() {
        return "wmsturnoverrulemiddle/wmsturnoverrulemiddle";
    }

    @RequestMapping(value = {"list", ""})
    public @ResponseBody
    ResultPage<WmsTurnoverRuleMiddle> getWmsTurnoverRuleMiddle(@RequestBody WmsTurnoverRuleMiddle entity, HttpSession session) {
        Page<WmsTurnoverRuleMiddle> list= baseService.baseSelectPage(entity);
            return renderPage(list);
    }

    @RequestMapping(value = "delete")
    public @ResponseBody
    JsonResult deleteWmsTurnoverRuleMiddle(@RequestBody List<String> ids) {
        Integer flag=baseService.baseDeleteBathPrimaryKeys(ids);
        return renderSuccess("删除成功");
    }

    @RequestMapping(value = "add")
    public @ResponseBody
    JsonResult addWmsTurnoverRuleMiddle(@RequestBody WmsTurnoverRuleMiddle entity) {
        entity.setId(UUIDUtils.uuid());
        baseService.baseInsert(entity);
        return renderSuccess("删除成功");
    }

    @RequestMapping(value = "getWmsTurnoverRuleMiddle/{id}")
    public @ResponseBody
    WmsTurnoverRuleMiddle getWmsTurnoverRuleMiddleById(@PathVariable("id") String id) {
        WmsTurnoverRuleMiddle entity=baseService.baseSelectByPrimaryKey(id);
        return entity;
    }
    @RequestMapping(value = "edit")
    public @ResponseBody
    JsonResult editWmsTurnoverRuleMiddle(@RequestBody WmsTurnoverRuleMiddle entity) {
        Integer flag=baseService.baseUpdateByPrimaryKeySelective(entity);
        return renderSuccess("删除成功");
    }
}
